fix: Ajustando whatsapp.bailey.service.ts para mostrar corretamente o…#2402
Open
jpavrdev wants to merge 2 commits intoEvolutionAPI:mainfrom
Open
fix: Ajustando whatsapp.bailey.service.ts para mostrar corretamente o…#2402jpavrdev wants to merge 2 commits intoEvolutionAPI:mainfrom
jpavrdev wants to merge 2 commits intoEvolutionAPI:mainfrom
Conversation
… QR Code que não estava aparecendo
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts WhatsApp Baileys disconnect handling to avoid an infinite reconnect loop during the initial connection phase so the QR code can be displayed correctly. Sequence diagram for updated WhatsApp Baileys disconnect and reconnect flowsequenceDiagram
actor User
participant WebApp
participant BaileysStartupService
participant WhatsAppServer
User->>WebApp: Open_whatsapp_connection_screen
WebApp->>BaileysStartupService: connectToWhatsapp(phoneNumber)
BaileysStartupService->>WhatsAppServer: initiate_connection
WhatsAppServer-->>BaileysStartupService: connection_update(qr_generated)
BaileysStartupService-->>WebApp: emit_qrcode(qrcode)
WebApp-->>User: display_qrcode
rect rgb(230,230,250)
WhatsAppServer-->>BaileysStartupService: connection_closed(lastDisconnect)
BaileysStartupService->>BaileysStartupService: determine_statusCode
BaileysStartupService->>BaileysStartupService: isInitialConnection = !instance.wuid && instance.qrcode.count == 0
alt initial_connection_and_qr_not_used_yet
BaileysStartupService->>BaileysStartupService: log Initial_connection_closed_wait_for_qr
BaileysStartupService-->>WhatsAppServer: no_reconnect
else subsequent_disconnect_and_shouldReconnect
BaileysStartupService->>BaileysStartupService: shouldReconnect = !codesToNotReconnect.includes(statusCode)
BaileysStartupService->>WhatsAppServer: reconnect_if_shouldReconnect
else disconnect_with_forbidden_or_logged_out
BaileysStartupService->>BaileysStartupService: stop_reconnect
end
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts:432` </location>
<code_context>
const shouldReconnect = !codesToNotReconnect.includes(statusCode);
+
+ // Check if this is the initial connection before QR code generation
+ const isInitialConnection = !this.instance.wuid && this.instance.qrcode.count === 0;
+
+ if (isInitialConnection) {
</code_context>
<issue_to_address>
**issue (bug_risk):** Guard against `this.instance.qrcode` being undefined before accessing `.count`.
If `qrcode` isn’t initialized when disconnect runs, this will throw at runtime. Consider a defensive access pattern (e.g. `this.instance.qrcode?.count ?? 0`) so this remains safe during unusual initialization or disconnect sequences.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Description
Correção de um problema onde o QR Code não estava aparecendo corretamente.
Foi feito um ajuste no arquivo
whatsapp.bailey.service.tspara garantir a exibição correta do código.🔗 Related Issue
🧪 Type of Change
🧪 Testing
📸 Screenshots (if applicable)
✅ Checklist
Summary by Sourcery
Bug Fixes: